package mammuthus.protocal

import akka.actor.ActorRef
import mammuthus.slave.InteractiveShellCommand

/**
 * 2/2/15 WilliamZhu(allwefantasy@gmail.com)
 */
case class RegisterAgent(hostName: String, slaveActorRef: ActorRef, slave: AgentInfo)

case class AppMessage(appInfo: AppInfo, hosts: List[String],ips:List[String])

case class AgentInfo(hostName: String,
                     ip: List[Eth],
                     cpuCores: Long,
                     memory: Long,
                     diskInfo: List[DiskInfo],
                     appInfo: List[AppInfo],
                     docker: Docker,
                     heartBeatTime: Long)

case class Docker(enable: Boolean, instances: List[DockerInstance])

case class DockerInstance(id: String,
                          ip: String,
                          registry: DockerRegistry)

case class DockerInstanceDetail(hostName: String, id: String,
                                names: List[String],
                                image: String,
                                create: Long,
                                status: String,
                                command: String,
                                ports: List[DockerInstancePort]
                                 )

case class DockerInstancePort(ip: String, privatePort: Int, publicPort: Int, ctype: String)

case class DockerRegistry(isRegistry: Boolean)

case class DiskInfo(devName: String, mountedDir: String, size: Long, used: Long)

case class CpuInfo(cpuCores: Long)

case class MemoryInfo(memory: Long)

case class AppInfo(appName: String, version: String, installPath: String,clientPort:Int,params:Map[String,String],pidInfo:List[Map[String, Map[String, String]]])

case class RegisterAgentSuccess()

case class UpdateConfigRequest(poolId: String, projectName: String)

case class UpdateConfigResponse(responseStr: String)

case class UpgradeApplicationRequest(poolId: String, projectName: String, tag: String)

case class UpgradeApplicationResponse(poolId: String, projectName: String, tag: String, message: String)

case class ExecuteShellCommandRequest(hostName: String, shellCommand: String, token: String,timeout:Long=InteractiveShellCommand.defaultTimeOut)

case class ExecuteShellCommandResponse(task: ShellTask, message: String)

case class ExecuteBlockShellCommandRequest(ecr: ExecuteShellCommandRequest)

case class ExecuteBlockShellCommandResponse(hostName: String, success: Boolean, message: String)

case class ExecuteDownloadCommandRequest(hostName: String, url: String, filePath: String)

case class BlockExecuteDownloadCommandRequest(hostName: String, url: String, filePath: String)

case class ExecuteDownloadCommandResponse(success: Boolean, msg: String, request: ExecuteDownloadCommandRequest)


case class ExecuteShellCommandProgressResponse(task: ShellTask, offset: Long, message: String, status:ShellExecuteStatus)

case class ShellExecuteStatus(finished: Boolean,isTimeout:Boolean,isError:Boolean)

case class ShellTask(taskId: String, hostName: String)

case class ShellProgressTask(task: ShellTask, offset: Long)

case class WriteFileTask(hostName: String, msg: String, path: String, append: Boolean)

case class WriteJSONFileTask(hostName: String, msg:Map[String,String], path: String)

case class WriteFileTaskResponse(hostName: String, success: Boolean, msg: String)

case class ExecuteMammuthusConfStartRequest(servers: String)

case class ExecuteMammuthusConfStartResponse()

case class AppLogRequest(hostName: String, filePath: String, offset: Long, size: Int)

case class AppLogResponse(hostName: String, filePath: String, offset: Long, msg: String, fileLen: Long)

case class ListAppLogRequest(hostName: String, filePath: String)

case class ListAppLogResponse(hostName: String, filePath: String, files: List[FileInfo])

case class FileInfo(name: String, isDirectory: Boolean, size: Long, lastModifyTime: Long)

case class DockerRequest(item: Any)

case class Eth(name:String,ipv4:String,ipv6:String)






